
#include <msParser.h>
#include <msZMat.h>
#include <msKineticOperator.h>
#include <msRepromodel.h>
#include <msPolynomial.h>

int main(int argc, char **argv) {
 
 using namespace atomism;

 // Test object creation
 boost::shared_ptr<msUnitsManager> unitMng = 	msUnitsManager::New();

 unitMng->set( "Angstrom Degree amu kcal/mol ps" );

 boost::shared_ptr<msScalarVariable> q0 = msScalarVariable::New("Angstrom");
 q0->set(5,0.5,6,0.1,0.1); q0->setId("q0");
 boost::shared_ptr<msScalarVariable> q1 = msScalarVariable::New("Degree");
 q1->set(120,0.,360,2,2); q1->setId("q1");
 boost::shared_ptr<msScalarVariable> q2 = msScalarVariable::New("Degree");
 q2->set(120,0.,360,2,2); q2->setId("q2");
 boost::shared_ptr<msScalarVariable> q3 = msScalarVariable::New("Degree");
 q3->set(120,0.,360,2,2); q3->setId("q3");

 boost::shared_ptr<msGeneralizedCoordinates> gcoors = 
					     msGeneralizedCoordinates::New(unitMng);
 gcoors->addVar(q0); gcoors->addVar(q1); gcoors->addVar(q2); gcoors->addVar(q3);

 boost::shared_ptr<msParser> kinfct0 = 	msParser::New("Angstrom");
 kinfct0->setCoordinates(gcoors);
 kinfct0->setExpression("q0");kinfct0->setId("f=q0");
 boost::shared_ptr<msParser> kinfct1 = 	msParser::New("Degree");
 kinfct1->setCoordinates(gcoors);
 kinfct1->setExpression("q1");kinfct1->setId("f=q1");
 boost::shared_ptr<msParser> kinfct2 = 	msParser::New("Degree");
 kinfct2->setCoordinates(gcoors);
 kinfct2->setExpression("q2");kinfct2->setId("f=q2");
 boost::shared_ptr<msParser> kinfct3 = 	msParser::New("Degree");
 kinfct3->setCoordinates(gcoors);
 kinfct3->setExpression("q3");kinfct3->setId("f=q3");
 
 boost::shared_ptr<msZMat> zmat =  		msZMat::New(unitMng);
 zmat->set("N N 0 1.1 N 1 5. 0 10. N 2 1.1 1 90. 0 0.");
 zmat->setId("zmat");

 boost::shared_ptr<msSystem> system =  		msSystem::New(unitMng);
 system->addEntity(zmat);
 
 boost::shared_ptr<msKineticOperator> kinop =  	msKineticOperator::New(unitMng);
 kinop->set(gcoors,system);
 kinop->addDynamicDof("zmat",0,kinfct0);
 kinop->addDynamicDof("zmat",1,kinfct1);
 kinop->addDynamicDof("zmat",2,kinfct2);
 kinop->addDynamicDof("zmat",3,kinfct3);
 

 boost::shared_ptr<msRepromodel> repro = msRepromodel::New("");
 repro->setCoordinates(gcoors);
 
 ifstream input("datafile.txt");
  
 char line[500];  bool eof=0;
 input.getline(line,500);
 vector<double> coors(gcoors->noOfDim(),0);
 boost::shared_ptr<msSamplerExplicit> sample=msSamplerExplicit::New();
 sample->print(cout);
 
 while(!eof){
       double value;
       for( size_t i=0; (i<gcoors->noOfDim()) && (!eof); i++) {
	   input>>coors[i];
	   eof=input.eof();
           }
       if( !eof) {
	   input>>value;
	   repro->addData(coors,value);
           }
       }
 input.close();
 
 return 0;
 }


